/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.userautentification.dao;

import java.util.ArrayList;

import com.userautentification.dao.imp.PersonaDaoImp;
import com.userautentification.dao.imp.RoleDaoImp;
import com.userautentification.entities.Address;
import com.userautentification.entities.Persona;
import com.userautentification.entities.Phone;
import com.userautentification.entities.Role;

public class Main {
    
    public static void main(String[] args) {
        
        // Create Dao object
        RoleDaoImp eventDao = new RoleDaoImp();
        
        // Perform create Dao operation
        System.out.println("Performing create Dao operation....");
        Role role = new Role();
        role.setName("Administrador");
        eventDao.create(role);
        
        Persona persona = new Persona();
        persona.setEmail("hola@hotmail.com");
        persona.setName("Maria");
        persona.setLastName("perez");
        persona.setAddress(new Address("san jeronimo 2121", "san vicente"));
        persona.setPhone(new ArrayList<Phone>());
        
        Phone phone = new Phone();
        phone.setNumber("21212");
        phone.setType("mobile");
        
        Phone phone2 = new Phone();
        phone2.setNumber("421212");
        phone2.setType("home");
        persona.getPhone().add(phone2);
        persona.getPhone().add(phone);
        
       PersonaDao personaDao = new PersonaDaoImp();
        
        personaDao.create(persona);
        
        // Perform find Dao operation
        System.out.println("Perrforming find Dao operation...");
        Role foundEvent = eventDao.find(role.getId());
        System.out.println("Name of the event found = " + foundEvent.getName());
        
        HibernateUtil.checkData("select * from ROLE");
        HibernateUtil.checkData("select * from persona");
        HibernateUtil.checkData("select * from phone");
        
    }
    
}